// pages/2411Ayiliao-pages/test-keypad.js
Page({
	data: {
		inputText: '',
		clickCount: 0,
		activeKey: null,
		keypadLayout: [
			['1', '2', '3'],
			['4', '5', '6'],
			['7', '8', '9'],
			['', '0', 'delete']
		]
	},

	handleKeyClick(e) {
		const key = e.currentTarget.dataset.key
		console.log('点击按键:', key)
		this.setData({
			clickCount: this.data.clickCount + 1
		})
		
		if (key === 'delete') {
			if (this.data.inputText.length > 0) {
				this.setData({
					inputText: this.data.inputText.slice(0, -1)
				})
			}
		} else if (key !== '') {
			this.setData({
				inputText: this.data.inputText + key
			})
		}
	},

	handleTouchStart(e) {
		const key = e.currentTarget.dataset.touchKey
		this.setData({
			activeKey: key
		})
	},

	handleTouchEnd() {
		this.setData({
			activeKey: null
		})
	},

	clearInput() {
		this.setData({
			inputText: '',
			clickCount: 0
		})
	}
}) 